<?

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#	FILE:			includes/flash/generatepagelist.php
#	FUNCTION:		Generates an XML document of pages in the current site
#	AUTHOR:			Cameron Morrow
#	CREATED:		26/07/2005
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Report all errors
error_reporting(E_ALL);

# Start session
session_start();

# Use this for IE to remember form data correctly
header("Cache-control: private");

# Vars
$ERROR_ARRAY = array();
$SQL_ARRAY = array();

# XML
header("content-type: text/xml");

# Includes
include "../../site_specific/project.php";
include "../../includes/constants.php";
include "../../includes/utilities.php";
include "../../includes/pages.php";
include "../../includes/database.php";
include "../../includes/users.php";
include "../../includes/files.php";

# Establish database connection
establishDatabaseConnection();

# Get pages
$pages = getRecord("SELECT p_id, p_name, p_parent, p_section, p_sort FROM " . $PROJECT_DB_TABLES["pages"] . " WHERE p_status<3 "." ORDER BY p_sort ASC, p_parent ASC");

# Open XML
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
echo "<pages sections=\"";

# Add sections
$sections = getSubDirectories("../../");

# Section names
$section_names = "";

# Strip out ignored directories
foreach ($sections as $section) {

	# Get index in list of non-useable folders
	$folder_index = findInArray($NON_SECTION_FOLDERS, $section);

	# If not in array
	if ($folder_index === false || $section == $NEWSLETTER_DIR_NAME) {

		# Add
		$section_names .= $section . ",";
	}
}

# Remove last comma
if ($section_names[strlen($section_names) - 1] == ",") {
	$section_names = substr($section_names, 0, strlen($section_names) - 1);
}

echo $section_names . "\">";

foreach ($pages as $page_id => $page) {
	echo "<page id=\"" . $page["p_id"] . "\" name=\"" . $page["p_name"] . "\" parent=\"" . $page["p_parent"] . "\" section=\"" . $page["p_section"] . "\" sort=\"" . $page["p_sort"] . "\" />";
}

echo "</pages>";





?>